<%--
  Created by IntelliJ IDEA.
  User: luo
  Date: 2020/7/6
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>理赔管理</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="static/lib/layui-v2.5.5/css/layui.css"  media="all">
    <link rel="stylesheet" type="text/css" href="static/lib/assets/waifu.css"/>
</head>
<body>

<fieldset class="layui-elem-field" style="padding: 30px;">
    <legend>查询条件</legend>
    <form class="layui-form" action="">
        <label class="layui-form-label"> 理赔编号:</label>
        <div class="layui-inline">
            <input class="layui-input" name="settlementId" id="settlementId" autocomplete="off">
        </div>
        保单号:
        <div class="layui-inline">
            <input class="layui-input" name="policyNum" id="policyNum" autocomplete="off">
        </div>
        <button type="button" class="layui-btn" data-type="reload" id="search">查询</button>
        <button onclick="window.location.reload();" type="reset" class="layui-btn layui-btn-primary">重置</button></br>
        </div>
     </from>
</fieldset>


    <fieldset class="layui-elem-field" style="padding: 30px;">
        <legend>理赔信息列表</legend>
        <button type="button" class="layui-btn add_claims"><i class="layui-icon layui-icon-add-1" style="font-size: 30px; color: #00FF00;"></i>新增理赔</button>
        <button type="button" class="layui-btn to_settlement"><i class="layui-icon layui-icon-search" style="font-size: 30px; color:  #87CEFA;"></i>理赔审核</button>
        <button type="button" class="layui-btn to_case"><i class="layui-icon layui-icon-search" style="font-size: 30px; color:  #87CEFA;"></i>案件状态</button>
        <button onclick="window.location.href='/claims/togame'" type="button" class="layui-btn i_game"><i class="layui-icon layui-icon-search" style="font-size: 30px; color:  #87CEFA;"></i>小游戏</button>
        <table lay-filter="claims" class="layui-hide" id="claims"></table>
        <button type="button" class="layui-btn del_claims"><i class="layui-icon layui-icon-delete" style="font-size: 30px; color: red;"></i>删除该理赔信息</button>
    </fieldset>

    <script src="static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>

    <script>
        var line = "";
        layui.use('table', function(){
            var layer = layui.layer;
            var table = layui.table;
            table.render({
                elem: '#claims'
                ,url:'claims/getClaims'
                ,cols: [[
                     {field:'index', minWidth:10, title: '',type:'numbers'}
                    ,{field:'settlementId', minWidth:10, title: '理赔编号', sort: true}
                    ,{field:'settlementAudit', minWidth:10, title: '理赔审核'}
                    ,{field:'policyNum', minWidth:10, title: '保单号', sort: true}
                    ,{field:'vin', minWidth:10, title: '车架号'}
                    ,{field:'receiptor', minWidth:10, title: '领取人'}
                    ,{field:'amountMoney', minWidth:10, title: '赔付金额', sort: true}
                    ,{field:'claimTyle', minWidth:10, title: '理赔方式'}
                    ,{field:'claimEvolve', minWidth:10, title: '理赔进展'}
                    ,{field:'signBillDate', minWidth:10, title: '签单日期', sort: true}
                    ,{field:'settleDate', minWidth:10, title: '结案时间', sort: true}
                    ,{field:'caseState', minWidth:10, title: '案件状态', sort: true}
                ]]
                ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    ,groups: 5 //只显示 3 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                    ,limits: [2, 5, 10]
                }
                ,id:'claims'
            });

            //监听行单击事件（双击事件为：rowDouble）
            table.on('row(claims)', function(obj){
                line = obj.data;
                //标注选中样式
                obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
            });

            var $ = layui.$, active = {
                reload: function(){
                    var settlementId = $('#settlementId');
                    var policyNum = $('#policyNum');
                    //执行重载
                    table.reload('claims', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        ,where: {
                            settlementId: settlementId.val(),
                            policyNum: policyNum.val()
                        }
                    }, 'data');
                }
            };

            $('#search').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });

            $('.add_claims').click(function () {
                layer.open({
                    type: 2,
                    title:'新增管理',
                    id: 'botn_1', //设定一个id，防止重复弹出
                    skin: 'layui-layer-rim', //加上边框
                    maxmin: true, //开启最大化最小化按钮
                    area: ['91%', '80%'],
                    content:"/claims/addSettlementPage"
                });
            });

            $('.to_settlement').click(function () {
                if (line=="") {
                    layer.msg("请先选择一行信息！");
                }else if(line.settlementAudit=="审核通过"){
                    layer.msg("该审核已通过！");
                } else {
                    layer.open({
                        type: 2,
                        title:'理赔审核',
                        id: 'botn_2', //设定一个id，防止重复弹出
                        skin: 'layui-layer-rim', //加上边框
                        maxmin: true, //开启最大化最小化按钮
                        area: ['90%', '80%'],
                        content:"/claims/settlementPage"
                    });
                }

            });

            $('.to_case').click(function () {
                if (line=="") {
                    layer.msg("请先选择一行信息！");
                }else{
                    layer.open({
                        type: 2,
                        title:'案件状态',
                        id: 'botn_3', //设定一个id，防止重复弹出
                        skin: 'layui-layer-rim', //加上边框
                        maxmin: true, //开启最大化最小化按钮
                        area: ['90%', '80%'],
                        content:"/claims/casePage"
                    });
                }
            });
            $(".i_game").hide();
            //监听提交
            $('.del_claims').on('click', function(){
                if (line=="") {
                    layer.msg("请先选择一行信息！");
                }else{
                    layer.open({
                        content: '确认要删除ID为'+line.settlementId+'的理赔信息吗？'
                        ,btn: ['确定', '取消']
                        ,yes: function(index, layero){
                            $.ajax({
                                url:'/claims/delSettlement',
                                type:'get',
                                data:{'settlementId':line.settlementId} ,
                                dataType:"json",
                                success:function(data){
                                    if(data){
                                        layer.msg("删除成功！");
                                        setTimeout(function () {
                                            //修改成功后刷新界面
                                            window.location.reload();
                                        }, 800);
                                    }
                                    else{
                                        layer.msg("删除失败！")
                                    }
                                },
                                error:function(e){
                                    layer.msg("删除失败！")
                                },

                            });
                            return false;
                        }
                        ,btn2: function(index, layero){
                            layer.close(index);
                        }
                    });
                }
            });
        });
    </script>
</body>
</html>
